import 'package:flutter/material.dart' ;
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:mfkb/config/Config.dart';
import 'package:mfkb/pages/modules/CustomRoute.dart';
import 'package:mfkb/pages/web/WebViewByUrl.dart';
import 'package:url_launcher/url_launcher.dart';
import 'Opinion.dart';

class About extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark ,
      child: Scaffold(
        body: Container(
          color: Color.fromARGB(255, 246, 245, 248),
          child: Column(
            children: <Widget>[
              Container(
                height: MediaQuery.of(context).padding.top ,
              ) ,
              Container(
                height: 45,
                child: Row(
                  children: <Widget>[
                    Container(
                      width: 17,
                      height: 17,
                      margin: EdgeInsets.only(left:ScreenUtil().setWidth(19)),
                      child: GestureDetector(
                        child: Container(
                          width: 17,
                          height: 17,
                          child: Image.asset("assets/images/back.png" , fit: BoxFit.fill,),
                        ),
                        onTap: (){
                          Navigator.of(context).pop() ;
                        },
                      ),
                    ) ,
                    Expanded(
                      child: Container(
                        child: Center(
                          child: Text("关于觅风" , style: TextStyle(
                            color: Color.fromARGB(255, 19 , 28 , 53) ,
                            fontSize: ScreenUtil().setSp(18) ,
                            fontWeight: FontWeight.bold 
                          ),),
                        ),
                      ),
                    ) ,
                    Container(
                      height: 17,
                      width: 36,
                    )
                  ],
                ),
              )  ,
              Container(
                width: ScreenUtil().setWidth(68),
                height: ScreenUtil().setWidth(68),
                margin: EdgeInsets.only(top:ScreenUtil().setHeight(46)),
                child: Center(
                  child: Image.asset("assets/images/logo.png" , fit: BoxFit.fill,),
                ),
              ) ,
              Container(
                margin: EdgeInsets.only(top:ScreenUtil().setHeight(13)),
                child: Text("觅风课表" , style: TextStyle(
                  color: Color.fromARGB(255, 19, 28, 53) ,
                  fontSize: ScreenUtil().setSp(14)
                ),),
              ) , 
              Container(
                margin: EdgeInsets.only(top:ScreenUtil().setHeight(15)), 
                child: Text("V"+Config().version.toString() , style: TextStyle(
                  color: Color.fromARGB(255, 121, 132, 155) ,
                  fontSize: ScreenUtil().setSp(12)
                ),),
              ) ,
              item(35 , "给我们评价" , "" , (){
                Navigator.of(context).push(CustomRoute(Opinion())) ;
              }) ,
              item(8 , "官方网站" , "" , () async{
                await launch("https://unixbw.cn/m/") ;
              }) ,
              item(8 , "用户反馈交流群/QQ" , "591474284" , () async{
                await launch("mqqapi://card/show_pslcard?src_type=internal&version=1&uin=591474284&card_type=group&source=qrcode") ;
              }) ,
              item(8 , "客服QQ" , "3299467716" , () async {
                await launch("mqqwpa://im/chat?chat_type=wpa&uin=3299467716&version=1&src_type=web&web_src=oicqzone.com") ;
              }) ,
            ],
          ),
        ),
      ),
    );
  }
  
  item(double top , String title , String msg , dynamic onClick){
    return GestureDetector(
      child: Container(
        margin: EdgeInsets.only(top:ScreenUtil().setHeight(top)),
        width: ScreenUtil().setWidth(345),
        height: ScreenUtil().setHeight(56),
        decoration: BoxDecoration(
          color: Colors.white , 
          borderRadius: BorderRadius.all(Radius.circular(8)) ,
          border:Border.all(
            color: Color.fromARGB(255, 236, 237, 241)
          )
        ),
        child: Row(
          children: <Widget>[
            Container(
              margin: EdgeInsets.only(left:ScreenUtil().setWidth(16)),
              child: Text(title , style: TextStyle(
                fontSize: ScreenUtil().setSp(14) ,
                color: Color.fromARGB(255, 19, 28, 53)
              ),),
            ) ,
            Expanded(
              child: Text(msg , textAlign: TextAlign.right,style: TextStyle(
                fontSize: ScreenUtil().setSp(14) ,
                color: Color.fromARGB(255, 0, 167, 187) ,
              ),),
            ) ,
            Container(
              width: ScreenUtil().setWidth(16),
              height: ScreenUtil().setWidth(16),
              margin: EdgeInsets.only(right:ScreenUtil().setWidth(10) , left:ScreenUtil().setWidth(6)),
              child: Image.asset("assets/images/more_2x.png" , fit:BoxFit.fill),
            )
          ],
        ),
      ) ,
      onTap: (){
        if(onClick != null){
          onClick() ;
        }
      },
    ) ;
  }
}